<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div>
            <router-link to="/index">首页</router-link>
            <router-link to="/list">列表页</router-link>
        </div>
        <router-view></router-view>
    </div>
    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>
    <template id="list">
        <ul>
            <li>列表1</li>
            <li>列表1</li>
            <li>列表1</li>
            <li>列表1</li>
        </ul>
    </template>
    <script>
        // 第一步：定义组件
        // Vue.component('index',{
        //     template:'<div>首页</div>'
        // })

        // Vue.component('list',{
        //     template:'#list'
        // })

        const Foo = { template: '<div>foo</div>' }
        const Bar = { template: '<div>bar</div>' }

        //第二步：路由规则列表
        let routes = [
            {
                path:'/index',
                component:Foo
            },
            {
                path:'/list',
                component:Bar
            }
        ];
        //第三步：new VueRouter()

        let router = new VueRouter({
            routes    //routes:routes
        })

        //第四步：把路由挂载到实例上
        new Vue({
            router   //router:router
        }).$mount('#app')
    </script>
</body>
</html>